$('#get_email').click(function () {

    var user_mail = document.getElementById('inputEmail').value;

    $.ajax({
        url: $SCRIPT_ROOT + '/register/get_email',
        type: 'post',
        data:{'user_mail':user_mail.toString()},
        dataType: 'json',
        success: function (data) {
            if(data.result.toString()==='1'){
                console.log(data.result)
            }else if (data.result.toString()==='0') {
                alert('操作失败，请重试！')
            }else if (data.result.toString()==='2'){
                alert('账户已注册！');
                window.location.href = $SCRIPT_ROOT + '/login';
            }
        },
        error: function (data) {
            alert('操作失败，请重试！')
        }
    })
});

$('#register').click(function () {
    var email = document.getElementById('inputEmail').value;
    var code = document.getElementById('code').value;
    var inputpassword = document.getElementById('inputpassword').value;
    var inputpassword2 = document.getElementById('inputpassword2').value;
    $.ajax({
        url: $SCRIPT_ROOT+'/reg',
        type:'post',
        data:{'email':email,'code':code,'password':inputpassword,'password2':inputpassword2},
        dataType: 'json',
        success:function (data) {
            if (data.result === 1){
                window.location.href = $SCRIPT_ROOT + '/login';
            }else if (data.result === 0){
                alert('操作失败，请重试！')
            }
        },
        error:function (data) {
            alert('操作失败，请重试！')
        }
    })
});